package com.estun.backroundManagementService.modules.testResult.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.estun.backroundManagementService.modules.testResult.mapper.TestResultMapper;
import com.estun.backroundManagementService.modules.testResult.model.TestResult;
import com.estun.backroundManagementService.modules.testResult.service.TestResultService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TestResultServiceImpl extends ServiceImpl<TestResultMapper, TestResult> implements TestResultService {
    /**
     * 获取待推送的测试数据
     */
    @Override
    public List<TestResult> getToBePushed() {
        QueryWrapper<TestResult> testResultQueryWrapper = new QueryWrapper<>();
        testResultQueryWrapper.ne("submit_status", 1);
        return list(testResultQueryWrapper);
    }

    @Override
    public boolean updatePushSucceed(List<Integer> idList, boolean success) {
        LambdaUpdateWrapper<TestResult> testResultLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
        testResultLambdaUpdateWrapper.in(TestResult::getId, idList)
                .set(TestResult::getSubmitStatus, success ? 1 : 2);
        return update(testResultLambdaUpdateWrapper);
    }
    // You can implement custom service logic here if needed
}
